|
14 | 14 |
|
15 | 15 | EXT_PATH = "./dist/vec0"
|
16 | 16 |
|
| 17 | +SUPPORTS_SUBTYPE = sqlite3.version_info[1] > 38 |
17 | 18 |
|
18 | 19 | def bitmap_full(n: int) -> bytearray:
|
19 | 20 | assert (n % 8) == 0
|
@@ -136,7 +137,8 @@ def test_vec_bit():
|
136 | 137 | vec_bit = lambda *args: db.execute("select vec_bit(?)", args).fetchone()[0]
|
137 | 138 | assert vec_bit(b"\xff") == b"\xff"
|
138 | 139 |
|
139 |
| - assert db.execute("select subtype(vec_bit(X'FF'))").fetchone()[0] == 224 |
| 140 | + if SUPPORTS_SUBTYPE: |
| 141 | + assert db.execute("select subtype(vec_bit(X'FF'))").fetchone()[0] == 224 |
140 | 142 |
|
141 | 143 | with pytest.raises(
|
142 | 144 | sqlite3.OperationalError, match="zero-length vectors are not supported."
|
@@ -165,7 +167,8 @@ def test_vec_f32():
|
165 | 167 | for test in tests:
|
166 | 168 | assert vec_f32(json.dumps(test)) == _f32(test)
|
167 | 169 |
|
168 |
| - assert db.execute("select subtype(vec_f32(X'00000000'))").fetchone()[0] == 223 |
| 170 | + if SUPPORTS_SUBTYPE: |
| 171 | + assert db.execute("select subtype(vec_f32(X'00000000'))").fetchone()[0] == 223 |
169 | 172 |
|
170 | 173 | with pytest.raises(
|
171 | 174 | sqlite3.OperationalError, match="zero-length vectors are not supported."
|
@@ -207,7 +210,9 @@ def test_vec_int8():
|
207 | 210 | vec_int8 = lambda *args: db.execute("select vec_int8(?)", args).fetchone()[0]
|
208 | 211 | assert vec_int8(b"\x00") == _int8([0])
|
209 | 212 | assert vec_int8(b"\x00\x0f") == _int8([0, 15])
|
210 |
| - assert db.execute("select subtype(vec_int8(?))", [b"\x00"]).fetchone()[0] == 225 |
| 213 | + |
| 214 | + if SUPPORTS_SUBTYPE: |
| 215 | + assert db.execute("select subtype(vec_int8(?))", [b"\x00"]).fetchone()[0] == 225 |
211 | 216 |
|
212 | 217 |
|
213 | 218 | def npy_cosine(a, b):
|
@@ -584,23 +589,19 @@ def test_smoke():
|
584 | 589 | db.execute("create virtual table vec_xyz using vec0( a float[2] )")
|
585 | 590 | assert execute_all(
|
586 | 591 | db,
|
587 |
| - "select name, ncol from pragma_table_list where name like 'vec_xyz%' order by name;", |
| 592 | + "select name from sqlite_master where name like 'vec_xyz%' order by name;", |
588 | 593 | ) == [
|
589 | 594 | {
|
590 | 595 | "name": "vec_xyz",
|
591 |
| - "ncol": 4, |
592 | 596 | },
|
593 | 597 | {
|
594 | 598 | "name": "vec_xyz_chunks",
|
595 |
| - "ncol": 4, |
596 | 599 | },
|
597 | 600 | {
|
598 | 601 | "name": "vec_xyz_rowids",
|
599 |
| - "ncol": 4, |
600 | 602 | },
|
601 | 603 | {
|
602 | 604 | "name": "vec_xyz_vector_chunks00",
|
603 |
| - "ncol": 2, |
604 | 605 | },
|
605 | 606 | ]
|
606 | 607 | chunk = db.execute("select * from vec_xyz_chunks").fetchone()
|
|
0 commit comments